def divide(self, dividend: int, divisor: int) -> int:
    if dividend == -2147483648 and divisor == -1:
        return 2147483647
    a, b, res = abs(dividend), abs(divisor), 0
    for x in range(32)[::-1]:
        if (a >> x) - b >= 0:
            a = a - (b << x)
            res = res + (1 << x)
    return res if (dividend > 0) == (divisor > 0) else -res
